package com.xja.controller;/**
 * @className: UserController
 * @description: TODO 类描述
 * @author: wkx
 * @date: 2022/4/14
 **/

import com.xja.pojo.User;
import com.xja.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @ClassName : UserController  //类名

 * @Author : Lenovo //作者
 * @Date: 2022/4/14  10:49
 */
@Controller
@RequestMapping("user")
public class UserController {
    private Logger logger = LoggerFactory.getLogger(UserController.class);
    @Reference(url = "dubbo://localhost:20881")
    UserService userService;

    @RequestMapping("login")
    public String login(User user, HttpSession session){

        User u = userService.login(user.getUsername());
        if (user.getPassword().equals(u.getPassword())) {
            session.setAttribute("user", user);
            return "1";
        }else {
            return "1";
        }

    }
}
